﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using DataLib.Common;
using DataLib.Accounts.Bus;

namespace Ewts.BaseData
{
    public partial class RubbishModify : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int id = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(id);
                }
            }
        }

        private void ShowInfo(int id)
        {
            DataLib.BLL.Rubbish bll = new DataLib.BLL.Rubbish();
            DataLib.Model.Rubbish model = bll.GetModel(id);
            this.lblid.Text = model.id.ToString();
            this.txtrubbishname.Text = model.itemName;
            this.txtrubbishcode.Text = model.itemCode;
            //this.ddlisdangerous.SelectedValue =model.isdangerous?"true":"false" ;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtrubbishname.Text.Trim().Length == 0)
            {
                strErr += "废弃物名称不能为空！\\n";
            }
            if (this.txtrubbishcode.Text.Trim().Length == 0)
            {
                strErr += "废弃物编码不能为空！\\n";
            }   
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int id = int.Parse(this.lblid.Text);

            string itemname = this.txtrubbishname.Text;
            string itemcode = this.txtrubbishcode.Text;
          


            DataLib.Model.Rubbish model = new DataLib.Model.Rubbish();
            model.id = id;

            model.itemName = itemname;
            model.itemCode = itemcode;
          

            DataLib.BLL.Rubbish bll = new DataLib.BLL.Rubbish();
            bll.Update(model);
            DataLib.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "RubbishList.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("RubbishList.aspx");
        }
    }
}